Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GT-2450 Add support for PageCollectionPages in CYOA tools #700

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

frett
Copy link
Contributor

@frett frett commented Oct 21, 2024

This adds support for parsing the new page collection page type for CYOA tools. This functionality is behind a new FEATURE_PAGE_COLLECTION feature flag that can be enabled when you are ready to use the functionality.

a PageCollectionPage contains a list of pages that should be rendered as a swipeable view pager.

TODO:

  • Figure out how to reference & handle parentPage when that parent is actually a page in a PageCollectionPage

Copy link

github-actions bot commented Oct 21, 2024

Typescript headers

  • kotlin-mpp-godtools-tool-parser-publishing-npm.d.ts

kotlin-mpp-godtools-tool-parser-publishing-npm.d.ts

--- a/home/runner/work/kotlin-mpp-godtools-tool-parser/kotlin-mpp-godtools-tool-parser/diff/base/kotlin-mpp-godtools-tool-parser-publishing-npm.d.ts
+++ b/home/runner/work/kotlin-mpp-godtools-tool-parser/kotlin-mpp-godtools-tool-parser/diff/head/kotlin-mpp-godtools-tool-parser-publishing-npm.d.ts
@@ -102,6 +102,7 @@ export declare namespace org.cru.godtools.shared.tool.parser {
             get FEATURE_CONTENT_CARD(): string;
             get FEATURE_FLOW(): string;
             get FEATURE_MULTISELECT(): string;
+            get FEATURE_PAGE_COLLECTION(): string;
         };
     }
 }
@@ -491,6 +492,16 @@ export declare namespace org.cru.godtools.shared.tool.parser.model {
         };
     }
 }
+export declare namespace org.cru.godtools.shared.tool.parser.model {
+    interface HasPages /* extends org.cru.godtools.shared.tool.parser.model.Base */ {
+        readonly _pages: kotlin.collections.KtList<org.cru.godtools.shared.tool.parser.model.page.Page>;
+        findPage(id: Nullable<string>): Nullable<org.cru.godtools.shared.tool.parser.model.page.Page>;
+        readonly pages: Array<org.cru.godtools.shared.tool.parser.model.page.Page>;
+        readonly __doNotUseOrImplementIt: {
+            readonly "org.cru.godtools.shared.tool.parser.model.HasPages": unique symbol;
+        };
+    }
+}
 export declare namespace org.cru.godtools.shared.tool.parser.model {
     /* @ts-ignore: extends class with private primary constructor */
     class Image extends org.cru.godtools.shared.tool.parser.model.Content implements org.cru.godtools.shared.tool.parser.model.Clickable {
@@ -589,7 +600,7 @@ export declare namespace org.cru.godtools.shared.tool.parser.model {
     }
 }
 export declare namespace org.cru.godtools.shared.tool.parser.model {
-    class Manifest /* extends org.cru.godtools.shared.tool.parser.model.BaseModel */ /* implements org.cru.godtools.shared.tool.parser.model.Styles */ {
+    class Manifest /* extends org.cru.godtools.shared.tool.parser.model.BaseModel */ implements org.cru.godtools.shared.tool.parser.model.HasPages/*, org.cru.godtools.shared.tool.parser.model.Styles */ {
         private constructor();
         get code(): Nullable<string>;
         get locale(): Nullable<string>;
@@ -603,11 +614,12 @@ export declare namespace org.cru.godtools.shared.tool.parser.model {
         set _pages(value: kotlin.collections.KtList<org.cru.godtools.shared.tool.parser.model.page.Page>);
         get shareables(): kotlin.collections.KtList<any/* org.cru.godtools.shared.tool.parser.model.shareable.Shareable */>;
         get relatedFiles(): kotlin.collections.KtSet<string>;
-        static createTestManifest(config?: org.cru.godtools.shared.tool.parser.ParserConfig, type?: org.cru.godtools.shared.tool.parser.model.Manifest.Type, code?: Nullable<string>, locale?: Nullable<string>, primaryColor?: string, primaryTextColor?: string, navBarColor?: Nullable<string>, navBarControlColor?: Nullable<string>, backgroundColor?: string, cardBackgroundColor?: Nullable<string>, categoryLabelColor?: Nullable<string>, pageControlColor?: string, multiselectOptionBackgroundColor?: Nullable<string>, multiselectOptionSelectedColor?: Nullable<string>, textColor?: string, textScale?: number, resources?: Nullable<(p0: org.cru.godtools.shared.tool.parser.model.Manifest) => kotlin.collections.KtList<org.cru.godtools.shared.tool.parser.model.Resource>>, shareables?: Nullable<(p0: org.cru.godtools.shared.tool.parser.model.Manifest) => kotlin.collections.KtList<any/* org.cru.godtools.shared.tool.parser.model.shareable.Shareable */>>, tips?: Nullable<(p0: org.cru.godtools.shared.tool.parser.model.Manifest) => kotlin.collections.KtList<any/* org.cru.godtools.shared.tool.parser.model.tips.Tip */>>, pages?: Nullable<(p0: org.cru.godtools.shared.tool.parser.model.Manifest) => kotlin.collections.KtList<org.cru.godtools.shared.tool.parser.model.page.Page>>): org.cru.godtools.shared.tool.parser.model.Manifest;
+        static createTestManifest(config?: org.cru.godtools.shared.tool.parser.ParserConfig, type?: org.cru.godtools.shared.tool.parser.model.Manifest.Type, code?: Nullable<string>, locale?: Nullable<string>, primaryColor?: string, primaryTextColor?: string, navBarColor?: Nullable<string>, navBarControlColor?: Nullable<string>, backgroundColor?: string, cardBackgroundColor?: Nullable<string>, categoryLabelColor?: Nullable<string>, pageControlColor?: string, multiselectOptionBackgroundColor?: Nullable<string>, multiselectOptionSelectedColor?: Nullable<string>, textColor?: string, textScale?: number, resources?: Nullable<(p0: org.cru.godtools.shared.tool.parser.model.Manifest) => kotlin.collections.KtList<org.cru.godtools.shared.tool.parser.model.Resource>>, shareables?: Nullable<(p0: org.cru.godtools.shared.tool.parser.model.Manifest) => kotlin.collections.KtList<any/* org.cru.godtools.shared.tool.parser.model.shareable.Shareable */>>, tips?: Nullable<(p0: org.cru.godtools.shared.tool.parser.model.Manifest) => kotlin.collections.KtList<any/* org.cru.godtools.shared.tool.parser.model.tips.Tip */>>, pages?: Nullable<(p0: org.cru.godtools.shared.tool.parser.model.Manifest) => kotlin.collections.KtList<org.cru.godtools.shared.tool.parser.model.page.Page>>, pageXmlFiles?: kotlin.collections.KtList<org.cru.godtools.shared.tool.parser.model.Manifest.XmlFile>): org.cru.godtools.shared.tool.parser.model.Manifest;
         get hasTips(): boolean;
-        findPage(id: Nullable<string>): Nullable<org.cru.godtools.shared.tool.parser.model.page.Page>;
         get dismissListeners(): Array<org.cru.godtools.shared.tool.parser.model.EventId>;
+        findPage(id: Nullable<string>): Nullable<org.cru.godtools.shared.tool.parser.model.page.Page>;
         get pages(): Array<org.cru.godtools.shared.tool.parser.model.page.Page>;
+        readonly __doNotUseOrImplementIt: org.cru.godtools.shared.tool.parser.model.HasPages["__doNotUseOrImplementIt"];
     }
     namespace Manifest {
         abstract class Type {
@@ -637,6 +649,13 @@ export declare namespace org.cru.godtools.shared.tool.parser.model {
             static values(): Array<org.cru.godtools.shared.tool.parser.model.Manifest.Type>;
             static valueOf(value: string): org.cru.godtools.shared.tool.parser.model.Manifest.Type;
         }
+        class XmlFile {
+            constructor(name: Nullable<string>, src: string);
+            copy(name?: Nullable<string>, src?: string): org.cru.godtools.shared.tool.parser.model.Manifest.XmlFile;
+            toString(): string;
+            hashCode(): number;
+            equals(other: Nullable<any>): boolean;
+        }
     }
 }
 export declare namespace org.cru.godtools.shared.tool.parser.model {
@@ -913,6 +932,7 @@ export declare namespace org.cru.godtools.shared.tool.parser.model.page {
         get id(): string;
         get position(): number;
         get parentPage(): Nullable<org.cru.godtools.shared.tool.parser.model.page.Page>;
+        get parentPageParams(): kotlin.collections.KtMap<string, string>;
         get nextPage(): Nullable<org.cru.godtools.shared.tool.parser.model.page.Page>;
         get previousPage(): Nullable<org.cru.godtools.shared.tool.parser.model.page.Page>;
         get isHidden(): boolean;

See the workflow run

Copy link

codecov bot commented Oct 21, 2024

Codecov Report

Attention: Patch coverage is 86.84211% with 15 lines in your changes missing coverage. Please review.

Project coverage is 86.01%. Comparing base (5b3acbb) to head (7311a03).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...hared/tool/parser/model/page/PageCollectionPage.kt 83.33% 1 Missing and 6 partials ⚠️
.../cru/godtools/shared/tool/parser/model/Manifest.kt 90.32% 1 Missing and 2 partials ⚠️
...cru/godtools/shared/tool/parser/model/page/Page.kt 90.90% 0 Missing and 3 partials ⚠️
.../cru/godtools/shared/tool/parser/model/HasPages.kt 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #700      +/-   ##
==========================================
- Coverage   86.15%   86.01%   -0.14%     
==========================================
  Files          93       95       +2     
  Lines        2260     2331      +71     
  Branches      529      550      +21     
==========================================
+ Hits         1947     2005      +58     
- Misses        123      126       +3     
- Partials      190      200      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Oct 21, 2024

iOS Framework headers

  • GodToolsToolParser.h

GodToolsToolParser.h

--- a/Users/runner/work/kotlin-mpp-godtools-tool-parser/kotlin-mpp-godtools-tool-parser/diff/base/GodToolsToolParser.h
+++ b/Users/runner/work/kotlin-mpp-godtools-tool-parser/kotlin-mpp-godtools-tool-parser/diff/head/GodToolsToolParser.h
@@ -6,9 +6,9 @@
 #import <Foundation/NSString.h>
 #import <Foundation/NSValue.h>
 
-@class GTTPAnalyticsActionNames, GTTPAnalyticsAppSectionNames, GTTPAnalyticsScreenNames, GTTPAnalyticsUserProperties, GTTPTutorialAnalyticsActionNames, GTTPTutorialAnalyticsAppSectionNames, GTTPKotlinEnumCompanion, GTTPKotlinEnum<E>, GTTPLogLevel, GTTPKotlinArray<T>, GTTPToolAnalyticsActionNames, GTTPToolAnalyticsScreenNames, GTTPCardCollectionPageCard, GTTPPage, GTTPLessonPage, GTTPTipPage, GTTPTractPage, GTTPTractPageCard, GTTPXmlPullParserFactory, GTTPParserConfig, GTTPParserResult, GTTPManifestParser, GTTPParserConfigCompanion, GTTPDeviceType, GTTPKotlinx_coroutines_coreCoroutineDispatcher, GTTPManifest, GTTPKotlinThrowable, GTTPParserResultError, GTTPBaseModel, GTTPState, GTTPFlowWatcher, GTTPParser_expressionsExpression, GTTPTip, GTTPContent, GTTPAccordionSection, GTTPAnalyticsEvent, GTTPAnalyticsEventTrigger, GTTPText, GTTPAnalyticsEventSystem, GTTPEventId, NSURL, GTTPResource, GTTPAspectRatio, UIColor, GTTPGravityHorizontal, GTTPButtonStyle, GTTPDimension, GTTPTextAlign, GTTPDimensionPercent, GTTPDimensionPixels, GTTPEventIdCompanion, GTTPFlowItem, GTTPFlowItemCompanion, GTTPFlow, GTTPGravityVertical, GTTPGravityCompanion, GTTPGravity, GTTPImageScaleType, GTTPInputError, GTTPInputType, GTTPInputErrorInvalidEmail, GTTPInputErrorRequired, GTTPManifestType, NSLocale, GTTPShareable, GTTPCategory, GTTPMultiselectOption, GTTPMultiselect, GTTPMultiselectOptionStyle, GTTPParagraph, GTTPSpacerMode, GTTPStylesCompanion, GTTPTabsTab, GTTPTextStyle, GTTPVideoProvider, GTTPCardCollectionPage, GTTPTipType, GTTPCallToAction, GTTPModal, GTTPHeader, GTTPHero, GTTPSaxXmlPullParserQName, GTTPSaxXmlPullParser, NSXMLParser, NSData, GTTPKotlinException, GTTPUserCounterNames, GTTPBadge, GTTPBadgeBadgeType, GTTPIconColors, GTTPUserActivity, GTTPUserActivityColors, GTTPButton, GTTPCommonThemeType, GTTPKotlinRuntimeException, GTTPKotlinIllegalStateException, GTTPKotlinAbstractCoroutineContextElement, GTTPKotlinx_coroutines_coreCoroutineDispatcherKey, GTTPColormathAnsi16, GTTPColormathAnsi256, GTTPKotlinFloatArray, GTTPColormathCMYK, GTTPColormathHPLuv, GTTPColormathHSL, GTTPColormathHSLuv, GTTPColormathHSV, GTTPColormathHWB, GTTPColormathICtCp, GTTPColormathJzAzBz, GTTPColormathJzCzHz, GTTPColormathLAB, GTTPColormathLCHab, GTTPColormathLCHuv, GTTPColormathLUV, GTTPColormathOklab, GTTPColormathOklch, GTTPColormathRGB, GTTPColormathXYZ, GTTPKotlinAbstractCoroutineContextKey<B, E>, GTTPColormathAnsi16Companion, GTTPColormathAnsi256Companion, GTTPKotlinFloatIterator, GTTPColormathCMYKCompanion, GTTPColormathHPLuvCompanion, GTTPColormathHSLCompanion, GTTPColormathHSLuvCompanion, GTTPColormathHSVCompanion, GTTPColormathHWBCompanion, GTTPColormathICtCpCompanion, GTTPColormathJzAzBzCompanion, GTTPColormathJzCzHzCompanion, GTTPColormathLABCompanion, GTTPColormathLCHabCompanion, GTTPColormathLCHuvCompanion, GTTPColormathLUVCompanion, GTTPColormathOklabCompanion, GTTPColormathOklchCompanion, GTTPColormathRGBCompanion, GTTPColormathRenderCondition, GTTPColormathXYZCompanion, GTTPColormathxyY, GTTPColormathColorComponentInfo, GTTPColormathWhitePoint;
+@class GTTPAnalyticsActionNames, GTTPAnalyticsAppSectionNames, GTTPAnalyticsScreenNames, GTTPAnalyticsUserProperties, GTTPTutorialAnalyticsActionNames, GTTPTutorialAnalyticsAppSectionNames, GTTPKotlinEnumCompanion, GTTPKotlinEnum<E>, GTTPLogLevel, GTTPKotlinArray<T>, GTTPToolAnalyticsActionNames, GTTPToolAnalyticsScreenNames, GTTPCardCollectionPageCard, GTTPPage, GTTPLessonPage, GTTPTipPage, GTTPTractPage, GTTPTractPageCard, GTTPXmlPullParserFactory, GTTPParserConfig, GTTPParserResult, GTTPManifestParser, GTTPParserConfigCompanion, GTTPDeviceType, GTTPKotlinx_coroutines_coreCoroutineDispatcher, GTTPManifest, GTTPKotlinThrowable, GTTPParserResultError, GTTPBaseModel, GTTPState, GTTPFlowWatcher, GTTPParser_expressionsExpression, GTTPTip, GTTPContent, GTTPAccordionSection, GTTPAnalyticsEvent, GTTPAnalyticsEventTrigger, GTTPText, GTTPAnalyticsEventSystem, GTTPEventId, NSURL, GTTPResource, GTTPAspectRatio, UIColor, GTTPGravityHorizontal, GTTPButtonStyle, GTTPDimension, GTTPTextAlign, GTTPDimensionPercent, GTTPDimensionPixels, GTTPEventIdCompanion, GTTPFlowItem, GTTPFlowItemCompanion, GTTPFlow, GTTPGravityVertical, GTTPGravityCompanion, GTTPGravity, GTTPImageScaleType, GTTPInputError, GTTPInputType, GTTPInputErrorInvalidEmail, GTTPInputErrorRequired, GTTPManifestType, NSLocale, GTTPShareable, GTTPManifestXmlFile, GTTPCategory, GTTPMultiselectOption, GTTPMultiselect, GTTPMultiselectOptionStyle, GTTPParagraph, GTTPSpacerMode, GTTPStylesCompanion, GTTPTabsTab, GTTPTextStyle, GTTPVideoProvider, GTTPCardCollectionPage, GTTPPageCollectionPageCompanion, GTTPTipType, GTTPCallToAction, GTTPModal, GTTPHeader, GTTPHero, GTTPSaxXmlPullParserQName, GTTPSaxXmlPullParser, NSXMLParser, NSData, GTTPKotlinException, GTTPUserCounterNames, GTTPBadge, GTTPBadgeBadgeType, GTTPIconColors, GTTPUserActivity, GTTPUserActivityColors, GTTPButton, GTTPCommonThemeType, GTTPKotlinRuntimeException, GTTPKotlinIllegalStateException, GTTPKotlinAbstractCoroutineContextElement, GTTPKotlinx_coroutines_coreCoroutineDispatcherKey, GTTPColormathAnsi16, GTTPColormathAnsi256, GTTPKotlinFloatArray, GTTPColormathCMYK, GTTPColormathHPLuv, GTTPColormathHSL, GTTPColormathHSLuv, GTTPColormathHSV, GTTPColormathHWB, GTTPColormathICtCp, GTTPColormathJzAzBz, GTTPColormathJzCzHz, GTTPColormathLAB, GTTPColormathLCHab, GTTPColormathLCHuv, GTTPColormathLUV, GTTPColormathOklab, GTTPColormathOklch, GTTPColormathRGB, GTTPColormathXYZ, GTTPKotlinAbstractCoroutineContextKey<B, E>, GTTPColormathAnsi16Companion, GTTPColormathAnsi256Companion, GTTPKotlinFloatIterator, GTTPColormathCMYKCompanion, GTTPColormathHPLuvCompanion, GTTPColormathHSLCompanion, GTTPColormathHSLuvCompanion, GTTPColormathHSVCompanion, GTTPColormathHWBCompanion, GTTPColormathICtCpCompanion, GTTPColormathJzAzBzCompanion, GTTPColormathJzCzHzCompanion, GTTPColormathLABCompanion, GTTPColormathLCHabCompanion, GTTPColormathLCHuvCompanion, GTTPColormathLUVCompanion, GTTPColormathOklabCompanion, GTTPColormathOklchCompanion, GTTPColormathRGBCompanion, GTTPColormathRenderCondition, GTTPColormathXYZCompanion, GTTPColormathxyY, GTTPColormathColorComponentInfo, GTTPColormathWhitePoint;
 
-@protocol GTTPKotlinComparable, GTTPBase, GTTPKotlinx_coroutines_coreFlow, GTTPVisibility, GTTPParent, GTTPHasAnalyticsEvents, GTTPClickable, GTTPStyles, GTTPParcelable, GTTPColormathColor, GTTPKotlinIterator, GTTPKotlinCoroutineContextKey, GTTPKotlinCoroutineContextElement, GTTPKotlinCoroutineContext, GTTPKotlinContinuation, GTTPKotlinContinuationInterceptor, GTTPKotlinx_coroutines_coreRunnable, GTTPKotlinx_coroutines_coreFlowCollector, GTTPColormathColorSpace, GTTPColormathHueColor, GTTPColormathLABColorSpace, GTTPColormathLCHabColorSpace, GTTPColormathLCHuvColorSpace, GTTPColormathLUVColorSpace, GTTPColormathRGBColorSpace, GTTPColormathXYZColorSpace, GTTPColormathWhitePointColorSpace, GTTPColormathRGBColorSpaceTransferFunctions;
+@protocol GTTPKotlinComparable, GTTPBase, GTTPKotlinx_coroutines_coreFlow, GTTPVisibility, GTTPParent, GTTPHasAnalyticsEvents, GTTPClickable, GTTPStyles, GTTPHasPages, GTTPParcelable, GTTPColormathColor, GTTPKotlinIterator, GTTPKotlinCoroutineContextKey, GTTPKotlinCoroutineContextElement, GTTPKotlinCoroutineContext, GTTPKotlinContinuation, GTTPKotlinContinuationInterceptor, GTTPKotlinx_coroutines_coreRunnable, GTTPKotlinx_coroutines_coreFlowCollector, GTTPColormathColorSpace, GTTPColormathHueColor, GTTPColormathLABColorSpace, GTTPColormathLCHabColorSpace, GTTPColormathLCHuvColorSpace, GTTPColormathLUVColorSpace, GTTPColormathRGBColorSpace, GTTPColormathXYZColorSpace, GTTPColormathWhitePointColorSpace, GTTPColormathRGBColorSpaceTransferFunctions;
 
 NS_ASSUME_NONNULL_BEGIN
 #pragma clang diagnostic push
@@ -356,6 +356,7 @@ __attribute__((swift_name("ParserConfig.Companion")))
 @property (readonly) NSString *FEATURE_CONTENT_CARD __attribute__((swift_name("FEATURE_CONTENT_CARD")));
 @property (readonly) NSString *FEATURE_FLOW __attribute__((swift_name("FEATURE_FLOW")));
 @property (readonly) NSString *FEATURE_MULTISELECT __attribute__((swift_name("FEATURE_MULTISELECT")));
+@property (readonly) NSString *FEATURE_PAGE_COLLECTION __attribute__((swift_name("FEATURE_PAGE_COLLECTION")));
 @end
 
 __attribute__((swift_name("ParserResult")))
@@ -750,6 +751,13 @@ __attribute__((swift_name("Gravity.Vertical")))
 @property (class, readonly) NSArray<GTTPGravityVertical *> *entries __attribute__((swift_name("entries")));
 @end
 
+__attribute__((swift_name("HasPages")))
+@protocol GTTPHasPages <GTTPBase>
+@required
+- (GTTPPage * _Nullable)findPageId:(NSString * _Nullable)id __attribute__((swift_name("findPage(id:)")));
+@property (readonly) NSArray<GTTPPage *> *pages __attribute__((swift_name("pages")));
+@end
+
 __attribute__((objc_subclassing_restricted))
 __attribute__((swift_name("Image")))
 @interface GTTPImage : GTTPContent <GTTPClickable>
@@ -836,10 +844,9 @@ __attribute__((swift_name("Link")))
 
 __attribute__((objc_subclassing_restricted))
 __attribute__((swift_name("Manifest")))
-@interface GTTPManifest : GTTPBaseModel <GTTPStyles>
-- (instancetype)initWithConfig:(GTTPParserConfig *)config type:(GTTPManifestType *)type code:(NSString * _Nullable)code locale:(NSLocale * _Nullable)locale primaryColor:(UIColor *)primaryColor primaryTextColor:(UIColor *)primaryTextColor navBarColor:(UIColor * _Nullable)navBarColor navBarControlColor:(UIColor * _Nullable)navBarControlColor backgroundColor:(UIColor *)backgroundColor cardBackgroundColor:(UIColor * _Nullable)cardBackgroundColor categoryLabelColor:(UIColor * _Nullable)categoryLabelColor pageControlColor:(UIColor *)pageControlColor multiselec

See the full diff from https://github.com/CruGlobal/kotlin-mpp-godtools-tool-parser/actions/runs/11488757388

See the workflow run

@frett frett force-pushed the cyoaPageCollections branch 5 times, most recently from 068aa1c to 631ee96 Compare October 22, 2024 16:25
@frett frett marked this pull request as ready for review October 22, 2024 16:38
this is meant as a temporary workaround to allow older versions of the parser to continue to depend upon the parent attribute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants